<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>节流</title>
  <link rel="stylesheet" href="../assets/css/common.css">
  <style>
    .count-wrap {
      margin: 30px 0;
      width: 200px;
      line-height: 200px;
      text-align: center;
      color: #000;
      background: #eee;
    }
  </style>
</head>

<body>
  <div class="page-wrap">
    <h3>若持续触发事件，节流间隔（此处为1s）内只会执行一次事件</h3>
    <div class="count-wrap" id="countWrap">0
    </div>
    <button class="common-btn" id="btn">click me</button>

  </div>
</body>
<script src="../assets/js/utils.js"></script>
<script>
  var count = 1
  const handleClick = (el) => {
    el.innerHTML = count++
  }

  const BTN = getEleById('btn')
  const WRAP = getEleById('countWrap')

  BTN.onclick = throttle(() => handleClick(WRAP), 1000)
</script>

</html>